/**
 * File: OutputStreamProvider.java
 * Created by: mhaimel
 * Created on: Aug 1, 2011
 * CVS:  $Id: OutputStreamProvider.java 1.0 Aug 1, 2011 3:55:00 PM mhaimel Exp $
 */
package uk.ac.ebi.curtain.storage.sequence;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * @author mhaimel
 *
 */
public class OutputStreamProvider implements StreamProvider<OutputStream> {
	
	private final File file;

	public OutputStreamProvider(File f) {
		this.file = f;
	}
	public OutputStreamProvider(String f) {
		this(new File(f));
	}

	@Override
	public OutputStream openAndGetStream() throws IOException {
		if(file.exists()){
			throw new IOException("File already exists!!!"  + file);
		}
		return new FileOutputStream(file,false);
	}

	@Override
	public String getName() {
		return file.toString();
	}
	
}
